<%@ page language="java" import="java.util.*" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Research</title>
<link href="/Bazi_na_Podatoci/css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
	<%
	Integer resQuantity = null;
	if(session.getAttribute("Resources")!=null){
		resQuantity = (Integer)session.getAttribute("Resources");
	}
	%>
	<div style="width: 100%;text-align:center;">
		Resources: <%=resQuantity%>
	</div>
	<div style="width: 300px;height: 100%; float: left">
		<a href="Overview" style="width: 300px;float: left">Overview</a>
		<a href="Structures" style="width: 300px;float: left">Structures</a>
		<a href="Research" style="width: 300px;float: left">Research</a>
		<a href="Barracks" style="width: 300px;float: left">Barracks</a>
		<a href="Island" style="width: 300px;float: left">Island</a>
		<a href="Movement" style="width: 300px;float: left">Movement Report</a>
		<a href="Messages" style="width: 300px;float: left">Messages</a>
	</div>
	
	</div>
	<div style="float: left;">
		<table border="1" cellspacing="0">
			<thead>
				<th>Name</th>
				<th>Price</th>
				<th>Level</th>
				<th></th>
			</thead>
<%
	
	
	ArrayList<Integer> ID = (ArrayList<Integer>)request.getAttribute("ID");
	ArrayList<String> NAME = (ArrayList<String>)request.getAttribute("NAME");
	ArrayList<Integer> LEVEL = (ArrayList<Integer>)request.getAttribute("LEVEL");
	ArrayList<Double> COST = (ArrayList<Double>)request.getAttribute("COST");
	
	Iterator<Integer> iter = ID.iterator();
	
	while(iter.hasNext()){
		Integer t_id =  iter.next();
		int index = ID.indexOf(t_id);
		%>
		<tr class="research <% 
		if(resQuantity!= null){
			if(resQuantity >= COST.get(index)){
				out.print("affordable");
			} else {
				out.print("non-affordable");
			}
		}%>">
			
				<td><%out.print(NAME.get(index));%></td>
				<td><%out.print(COST.get(index).intValue());%></td>
				<td><%out.print(LEVEL.get(index));%></td>
				<td>
					<form action="Research" method="post">
						<input type="hidden" value="<%out.print(t_id); %>" name="rid" />
						<input type="submit" value="Research Technology"/>
					</form>
				</td>
				
		</tr>
		
		<%
	}
%>
		</table>
	</div>
</body>
</html>